<?php
require_once '../model/model.php';
use admin\Model\model as m;

$m = new m();

if (!empty($_POST['oper']) && $_POST['oper'] == 'del') {
	if (!empty($_POST['id'])) {
		$id = $_POST['id'];
		exit($m->del('depart',$id));
	}
}else if (!empty($_POST['oper']) && $_POST['oper'] == 'edit') {
	if (!empty($_POST['id'])) {
		$id = $_POST['id'];
		$name = $_POST['d_name'];
		exit($m->update_depart('depart',$id,$name));
	}
}else if (!empty($_POST['oper']) && $_POST['oper'] == 'add') {
	if (!empty($_POST['id'] && $_POST['id'] == '_empty')) {
		$id = 'null';
		$name = $_POST['d_name'];
		exit($m->depart_add('depart',$id,$name));
	}
}else if(!empty($_GET['search'] && $_GET['search'] == 'true')){
	$d = $m->d_search();
	exit(json_encode($d,JSON_UNESCAPED_UNICODE));
}